/*
 * Copyright (C) 2010 TopCoder Inc., All Rights Reserved.
 */
package com.hercules.android.receiver.entities;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import android.os.Handler;
import android.widget.VideoView;

import com.hercules.android.receiver.painter.XREPainter;

/**
 * <p>
 * An POJO containing the common data used by the application.
 * </p>
 * 
 * @author TCSASSEMBER
 * @version 1.0
 */
public class XREApplicationData {
    /**
     * Represents the mapping from resourceId to XREResource.
     */
    private Map<Integer, XREObject> elementsXREIdToElement;

    /**
     * Represents the mapping from the type of XREResource to the associated XREPainter.
     */
    private Map<String, XREPainter> objectPainters;

    /**
     * Represents the current command index.
     */
    private int currentCommandIndex;

    /**
     * Represents the sessionGUID of the connection.
     */
    private String sessionGUID;

    /**
     * Represents the handler to update root view.
     */
    private Handler rootViewUpdateHandler;

    /**
     * Represents the handler to update the whole layout view.
     */
    private Handler layoutRefreshHandler;

    /**
     * Represents the handler to tell the main activity to show a dialog.
     */
    private Handler showDialogHandler;

    /**
     * Represents the handler to set the connection view.
     */
    private Handler showConnectionViewHandler;

    /**
     * Represents the object to synchronize the common data between different threads.
     */
    private Object dataLockObject = new Object();

    /**
     * A <code>List</code> contains all the <code>VideoView</code> used by this application.
     */
    private List<VideoView> videos = new ArrayList<VideoView>();

    /**
     * Gets the mapping from resourceId to XREResource.
     * 
     * @return the mapping from resourceId to XREResource
     */
    public Map<Integer, XREObject> getElementsXREIdToElement() {
        return elementsXREIdToElement;
    }

    /**
     * Sets the mapping from resourceId to XREResource.
     * 
     * @param elementsXREIdToElement
     *            the mapping from resourceId to XREResource
     */
    public void setElementsXREIdToElement(Map<Integer, XREObject> elementsXREIdToElement) {
        this.elementsXREIdToElement = elementsXREIdToElement;
    }

    /**
     * Gets the mapping from the type of XREResource to the associated XREPainter.
     * 
     * @return the mapping from the type of XREResource to the associated XREPainter
     */
    public Map<String, XREPainter> getObjectPainters() {
        return objectPainters;
    }

    /**
     * Sets the mapping from the type of XREResource to the associated XREPainter.
     * 
     * @param objectPainters
     *            the mapping from the type of XREResource to the associated XREPainter
     */
    public void setObjectPainters(Map<String, XREPainter> objectPainters) {
        this.objectPainters = objectPainters;
    }

    /**
     * Gets the current command index.
     * 
     * @return the current command index
     */
    public int getCurrentCommandIndex() {
        return currentCommandIndex;
    }

    /**
     * Sets the current command index.
     * 
     * @param currentCommandIndex
     *            the current command index.
     */
    public void setCurrentCommandIndex(int currentCommandIndex) {
        this.currentCommandIndex = currentCommandIndex;
    }

    /**
     * Gets the sessionGUID.
     * 
     * @return the sessionGUID
     */
    public String getSessionGUID() {
        return sessionGUID;
    }

    /**
     * Sets the sessionGUID.
     * 
     * @param sessionGUID
     *            the sessionGUID to set
     */
    public void setSessionGUID(String sessionGUID) {
        this.sessionGUID = sessionGUID;
    }

    /**
     * Gets the handler to update the root view.
     * 
     * @return the handler to update the root view
     */
    public Handler getRootViewUpdateHandler() {
        return rootViewUpdateHandler;
    }

    /**
     * Sets the handler to update the root view.
     * 
     * @param rootViewUpdateHandler
     *            the handler to update the root view
     */
    public void setRootViewUpdateHandler(Handler rootViewUpdateHandler) {
        this.rootViewUpdateHandler = rootViewUpdateHandler;
    }

    /**
     * Gets the object to synchronize the common data between different threads.
     * 
     * @return the dataLockObject the object to synchronize the common data between different threads
     */
    public Object getDataLockObject() {
        return dataLockObject;
    }

    /**
     * Gets the videos.
     * 
     * @return A <code>List</code> contains all the <code>VideoView</code> used by this application.
     */
    public List<VideoView> getVideos() {
        return videos;
    }

    /**
     * Sets the videos.
     * 
     * @param videos
     *            A <code>List</code> contains all the <code>VideoView</code> used by this application.
     */
    public void setVideos(List<VideoView> videos) {
        this.videos = videos;
    }

    /**
     * Gets the handler to update the whole layout view.
     * 
     * @return the handler to update the whole layout view
     */
    public Handler getLayoutRefreshHandler() {
        return layoutRefreshHandler;
    }

    /**
     * Sets the handler to update the whole layout view.
     * 
     * @param layoutRefreshHandler
     *            the handler to update the whole layout view
     */
    public void setLayoutRefreshHandler(Handler layoutRefreshHandler) {
        this.layoutRefreshHandler = layoutRefreshHandler;
    }

    /**
     * Gets the showDialogHandler.
     * 
     * @return the showDialogHandler
     */
    public Handler getShowDialogHandler() {
        return showDialogHandler;
    }

    /**
     * Sets the showDialogHandler.
     * 
     * @param showDialogHandler
     *            the showDialogHandler to set
     */
    public void setShowDialogHandler(Handler showDialogHandler) {
        this.showDialogHandler = showDialogHandler;
    }

    /**
     * Gets the handler to set the connection view.
     * 
     * @return the handler to set the connection view.
     */
    public Handler getShowConnectionViewHandler() {
        return showConnectionViewHandler;
    }

    /**
     * Sets the handler to set the connection view.
     * 
     * @param showConnectionViewHandler
     *            the handler to set the connection view.
     */
    public void setShowConnectionViewHandler(Handler showConnectionViewHandler) {
        this.showConnectionViewHandler = showConnectionViewHandler;
    }
}
